package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

public class ListBox extends Shape {
   private ArrayList a;
   private int b;
   private int c;
   private int d = 0;
   private int e = 0;
   private int A = 1;
   private int B = 8;

   ListBox(ShapeCollection shapes) {
      super(shapes, 18, shapes);
   }

   public int getItemCount() {
      if (this.v == null) {
         return 0;
      } else {
         Range var1 = this.Y();
         return var1 == null ? 0 : var1.getRowCount();
      }
   }

   public int getSelectedIndex() {
      return this.a != null && this.a.size() != 0 ? (Integer)this.a.get(0) : -1;
   }

   public void setSelectedIndex(int value) {
      Cell var2 = this.e(true);
      if (var2 != null) {
         int var3;
         int var4;
         if (this.b == 1) {
            if (var2.getType() == 4) {
               var3 = var2.getIntValue();
               var4 = this.getItemCount();
               if (var3 > var4) {
                  var3 = var4;
               }

               var2.putValue(var3);
            } else {
               var2.putValue(0);
            }
         } else if (value >= 0) {
            var3 = value + 1;
            var4 = this.getItemCount();
            if (var3 > var4) {
               var3 = var4;
            }

            var2.putValue(var3);
         } else {
            var2.putValue((String)null);
         }
      }

      if (value == -1) {
         this.a = null;
      } else if (value >= 0 && value <= 65535) {
         if (this.a == null) {
            this.a = new ArrayList();
         }

         this.a.clear();
         com.aspose.cells.b.a.a.ze.a(this.a, (Object)value);
      } else {
         throw new IllegalArgumentException("Invalid selected index.");
      }
   }

   void a(int var1) {
      if (var1 == -1) {
         this.a = null;
      } else {
         this.a = new ArrayList();
         com.aspose.cells.b.a.a.ze.a(this.a, (Object)var1);
      }
   }

   public void selectedItem(int itemIndex, boolean isSelected) {
      if (itemIndex >= 0 && itemIndex < this.getItemCount()) {
         if (this.getSelectionType() != 0 && this.a != null && this.a.size() != 0) {
            boolean var3 = false;

            for(int var4 = 0; var4 < this.a.size(); ++var4) {
               if (((Integer)this.a.get(var4) & '\uffff') == itemIndex) {
                  var3 = true;
                  if (!isSelected) {
                     this.a.remove(var4);
                  }
                  break;
               }
            }

            if (isSelected && !var3) {
               com.aspose.cells.b.a.a.ze.a(this.a, (Object)itemIndex);
            }

         } else {
            if (isSelected) {
               this.setSelectedIndex(itemIndex);
            } else {
               this.setSelectedIndex(-1);
            }

         }
      } else {
         throw new IllegalArgumentException("Invalid selected index.");
      }
   }

   public boolean isSelected(int itemIndex) {
      if (this.a != null && this.a.size() != 0) {
         Iterator var2 = this.a.iterator();

         int var3;
         do {
            if (!var2.hasNext()) {
               return false;
            }

            var3 = (Integer)var2.next();
         } while((var3 & '\uffff') != itemIndex);

         return true;
      } else {
         return false;
      }
   }

   public Cell[] getSelectedCells() {
      if (this.v != null && this.a != null && this.a.size() != 0) {
         ArrayList var1 = new ArrayList();
         Range var2 = this.d(this.v);
         int var4;
         if (var2 != null) {
            Iterator var3 = this.a.iterator();

            while(var3.hasNext()) {
               var4 = (Integer)var3.next();
               com.aspose.cells.b.a.a.ze.a(var1, (Object)var2.get(var4 & '\uffff', 0));
            }
         }

         Cell[] var5 = new Cell[var1.size()];

         for(var4 = 0; var4 < var5.length; ++var4) {
            var5[var4] = (Cell)var1.get(var4);
         }

         return var5;
      } else {
         return null;
      }
   }

   ArrayList a() {
      return this.a;
   }

   void a(ArrayList var1) {
      this.a = var1;
   }

   public boolean getShadow() {
      return this.z;
   }

   public void setShadow(boolean value) {
      this.z = value;
   }

   public int getSelectionType() {
      return this.b;
   }

   public void setSelectionType(int value) {
      this.b = value;
   }

   int b() {
      return this.c;
   }

   void b(int var1) {
      this.c = var1;
   }

   int c() {
      return this.d;
   }

   void c(int var1) {
      this.d = var1;
   }

   int d() {
      return this.e;
   }

   void d(int var1) {
      this.e = var1;
   }

   int e() {
      return this.A;
   }

   void e(int var1) {
      this.A = var1;
   }

   public int getPageChange() {
      return this.B;
   }

   public void setPageChange(int value) {
      this.B = value;
   }

   void a(ListBox var1, CopyOptions var2) {
      super.a((Shape)var1, (CopyOptions)var2);
      this.c = var1.c;
      this.d = var1.d;
      this.e = var1.e;
      this.A = var1.A;
      this.B = var1.B;
      this.b = var1.b;
      this.z = var1.z;
      this.v = zyd.a(var1.L(), this.L(), var1.v, 0, 0, 0);
      if (var1.a != null) {
         this.a = new ArrayList();
         Iterator var3 = var1.a.iterator();

         while(var3.hasNext()) {
            int var4 = (Integer)var3.next();
            com.aspose.cells.b.a.a.ze.a(this.a, (Object)var4);
         }
      } else {
         this.a = null;
      }

   }
}
